Guild icon
Project Sekai
🔒 UMDCTF 2023 / ✅-hwrf-beep-boop
Avatar
beep-boop - 500 points
Category: Hw+Rf Description: "Oh why didn't I just choose Computer Science??" -Every Computer Engineering major Author: Assgent Files:Tags: No tags.
Sutx pinned a message to this channel. 04/28/2023 3:01 PM
Avatar
@Violin wants to collaborate 🤝
Avatar
@fleming wants to collaborate 🤝
Avatar
ok looks like a rev
21:24
can be bruted char by char i think
21:25
function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
21:25
pretty sure flag chars dont affect each other
21:25
so maybe just brute and listen?
Avatar
@Sheep wants to collaborate 🤝
Avatar
yeah, loop through each flag character: x = [x, pause, cos(26*pi*char*t)+cos(22*pi*(char-50)*t), pause]
Avatar
i cant use matlab
23:10
lol
23:10
but i think we basically just use matlab to parse data
23:11
sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); They did this, sp we can recover it i guess
Avatar
why virtualbox cant copy paste lol
23:12
can you copy to here sahuang
23:12
all the code
Avatar
%Build script to beep-boop (UMDCTF2023, author: Assgent) %{ A flag was encoded into a sound file using the script below. Analyze the script and reverse-engineer the flag! %} close clear all flag = fileread("flag.txt"); Fs = 8192; sound = string_to_sound(flag, Fs, 1, 0.5); sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end % Fs is the samples/sec. % T is the duration of each key. (in seconds) % Tpause is the pause between keys. (in seconds) function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
Avatar
[x, Fs] = audioread('sound.wav'); fc = 500; % frekuensi cutoff (Hz) [b, a] = butter(4, fc/(Fs/2), 'high'); x_filtered = filter(b, a, x); threshold = 0.2; x_noisy = abs(x_filtered); x_noisy(x_noisy < threshold) = 0; T = 1/Fs; % N = length(x_noisy); % t = (0:N-1)*T; % f = (0:N-1)*(Fs/N); % freq1 = zeros(length(t),1); freq2 = zeros(length(t),1); for n = 1:length(t) s = x_noisy(n); if s ~= 0 freq1(n) = round(s/13); freq2(n) = round(s/11) + 50; end end flag = ''; for n = 1:length(freq1) if freq1(n) ~= 0 && freq2(n) ~= 0 c = char([freq1(n), freq2(n)]); flag = strcat(flag, c); end end disp(flag); (edited)
Avatar
does this work?
Avatar
no sad
Avatar
you can actually make a flag and test custom input
23:27
you didnt take into account the normalize?
Avatar
if its not solved by tmr im gonna use chatgpt and try
Avatar
@Violin
Avatar
Avatar
Violin
[x, Fs] = audioread('sound.wav'); fc = 500; % frekuensi cutoff (Hz) [b, a] = butter(4, fc/(Fs/2), 'high'); x_filtered = filter(b, a, x); threshold = 0.2; x_noisy = abs(x_filtered); x_noisy(x_noisy < threshold) = 0; T = 1/Fs; % N = length(x_noisy); % t = (0:N-1)*T; % f = (0:N-1)*(Fs/N); % freq1 = zeros(length(t),1); freq2 = zeros(length(t),1); for n = 1:length(t) s = x_noisy(n); if s ~= 0 freq1(n) = round(s/13); freq2(n) = round(s/11) + 50; end end flag = ''; for n = 1:length(freq1) if freq1(n) ~= 0 && freq2(n) ~= 0 c = char([freq1(n), freq2(n)]); flag = strcat(flag, c); end end disp(flag); (edited)
can you send me the value of x,fs?
07:33
dont have matlab installed
07:33
need to sanity check if python gets same output
Avatar
wait wait, its not correct
07:39
i think this chal should be easy
07:40
max(abs(sound)) we just miss this
07:46
cos+cos
07:46
maybe max is 2
07:46
ill need to verify from matlab..
07:46
or if you can help
Avatar
Avatar
sahuang
%Build script to beep-boop (UMDCTF2023, author: Assgent) %{ A flag was encoded into a sound file using the script below. Analyze the script and reverse-engineer the flag! %} close clear all flag = fileread("flag.txt"); Fs = 8192; sound = string_to_sound(flag, Fs, 1, 0.5); sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end % Fs is the samples/sec. % T is the duration of each key. (in seconds) % Tpause is the pause between keys. (in seconds) function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
@Violin run this with flag UMDCTF{test_flag}
07:47
then print max(abs(sound))
07:47
im expecting it to be 2
07:47
if so we can just brute each segment values with char 32-126 to see if values match
Avatar
close clear all flag = "UMDCTF{test_flag}"; Fs = 8192; sound = string_to_sound(flag, Fs, 1, 0.5); sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end % Fs is the samples/sec. % T is the duration of each key. (in seconds) % Tpause is the pause between keys. (in seconds) function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
07:50
like that?
Avatar
after sound_normalized can you print max(abs(sound))?
07:51
just wanna see the coeff
07:52
if i can setup codespace i can prob do it
07:52
cuz it feels that we just need to brute each length of t the valued and match the correct char
Avatar
clear all flag = "UMDCTF{test_flag}"; Fs = 8192; sound = string_to_sound(flag, Fs, 1, 0.5); sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); disp(max(abs(sound))); function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end % Fs is the samples/sec. % T is the duration of each key. (in seconds) % Tpause is the pause between keys. (in seconds) function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
Avatar
yeah
07:53
ill try octave online see if it compiles
Avatar
Avatar
Violin
clear all flag = "UMDCTF{test_flag}"; Fs = 8192; sound = string_to_sound(flag, Fs, 1, 0.5); sound_normalized = sound / (max(abs(sound))); audiowrite("sound.wav", sound_normalized, Fs); disp(max(abs(sound))); function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end % Fs is the samples/sec. % T is the duration of each key. (in seconds) % Tpause is the pause between keys. (in seconds) function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end
do you have the number?
08:19
doing it rn
08:43
yep it seems 2
08:43
ok good news
08:45
t is just range(0, 1, 1/8193) (edited)
08:47
length(x)=626739
08:47
51*12289
08:47
so 51 chars
08:53
08:53
yep
08:54
so they are x2
Avatar
Avatar
sahuang
used /ctf solve
✅ Challenge solved.
Avatar
GOATTTT
09:02
how
Avatar
Fs = 8192; function freq = get_frequency_1(char) freq = char * 13; end function freq = get_frequency_2(char) freq = (char - 50) * 11; end function x = string_to_sound(keys,Fs,T,Tpause) t = (0:fix(T*Fs)).'/Fs ; zp = zeros(fix(Tpause*Fs/2),1) ; x = []; for r = 1:length(keys(:)) char = keys(r); x = [x ; zp ; cos(2*pi*get_frequency_1(char)*t) + cos(2*pi*get_frequency_2(char)*t) ; zp]; end end % our script [y, Fs] = audioread('sound.wav'); y = y * 2; for r = 0:50 sub = y(r*12289+1:(r+1)*12289); for char = 32:126 x = string_to_sound(char,Fs,1,0.5); if sum(abs(sub(2048:2058)-x(2048:2058))) < 0.001 disp(char); end end end (edited)
09:02
its very easy
09:02
10 lines
Avatar
ah im dumb msfrog
09:03
gg
Exported 70 message(s)